package com.omi.iberolactalpreventa.objects;

import java.util.ArrayList;

import com.omi.iberolactalpreventa.R;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AdapterItmPedlst extends BaseAdapter{
	
	Activity activity;
	ArrayList<ItmPedLst> items;

	
	public AdapterItmPedlst(Activity activity, ArrayList<ItmPedLst> items) {
		this.activity = activity;
		this.items = items;
	}

	@Override
	public int getCount() {
		return items.size();
	}

	@Override
	public Object getItem(int position) {
		return items.get(position);
	}

	@Override
	public long getItemId(int position) {
		return items.get(position).getId();
	}

	@Override
	public View getView(int position, View view, ViewGroup grp) 
	{
		View v = view;
		
		if(view==null)
		{
			LayoutInflater inf = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = inf.inflate(R.layout.item_pedlst, null);
		}
		
		ItmPedLst itm = items.get(position);
		
		TextView txtpedlstDescripcion = (TextView) v.findViewById(R.id.txtpedlstDescripcion);
		txtpedlstDescripcion.setText(itm.getDescripcion());
		TextView txtpedlstCodigo = (TextView) v.findViewById(R.id.txtpedlstCodigo);
		txtpedlstCodigo.setText(itm.getCodigo());
		TextView txtpedlstCantidad = (TextView) v.findViewById(R.id.txtpedlstCantidad);
		txtpedlstCantidad.setText(itm.getCantidad());
		TextView txtpedlstUds = (TextView) v.findViewById(R.id.txtpedlstUds);
		txtpedlstUds.setText(itm.getUds());
		TextView txtpedlstUd = (TextView) v.findViewById(R.id.txtpedlstUd);
		txtpedlstUd.setText(itm.getUd());
		TextView txtpedlstImpLin = (TextView) v.findViewById(R.id.txtpedlstImpLin);
		txtpedlstImpLin.setText(itm.getImporteLinea());
		
		return v;
	}

}
